package usb;
import java.util.Scanner;

public class Test08 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int random=(int)(Math.random() * 100);
        int num =0;
        int i=0;
        for(i=9;i>=0;i--){
            System.out.println("请输入数字");
            num = sc.nextInt();
            if (num>random) {
                if (i==0){
                    System.out.println("游戏结束，你输了");
                    break;
                }else {
                    System.out.println("猜大了");
                    System.out.println("还有"+i+"次机会");
                }
            }else if (num<random){
                if (i==0){
                    System.out.println("游戏结束，你输了");
                    break;
                }else {
                    System.out.println("猜小了");
                    System.out.println("还有"+i+"次机会");
                }
            }else {
                System.out.println("猜对了，你赢了");
                break;
            }
        }
    }
}
